<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/adminHead.jsp"%>
<script type="text/javascript">
var sendMenuInfo = function(){
	var menuIndex = '<c:out value="${menu.menuIndex}"/>';
	var morder = $('#morder').val();
	var menuName = $('#menuName').val();
	var useFlag = $('#useFlag').is(':checked')?1:0;

  	var url='/admin/getAdminMenuUpdate.json';
	
  	if(isNaN(morder) || morder.length==0){
  		alert('order ')
		return;
  	}
  	
  	if(menuName.length==0){
  		alert('메뉴명이 없습니다.');
  		return;
  	}
	var param={
			menuIndex:menuIndex,
			morder:morder,
			menuName:menuName,
			useFlag:useFlag
	};
	
  	
	AjaxPost(url, param, function(data){

		alert(data.result);

		location.replace("/admin/adminMenuMain");
	});

};



function isNum(obj){ 
	  var val=obj.value;

		re=/[^0-9]/gi;
		if(re.test(val)) {
			alert('숫자만 입력가능합니다.');
			obj.value = "";
			obj.focus();
			return;
		}
	}
</script>
  <TR>
    <TD height="%" valign="top">
      <TABLE width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <TBODY>
        <TR>
          <TD width="186" height="%" align="right" valign="top"><!-- Left Menu table 시작 --------------------------------> 
                        
            <TABLE width="176" height="100%" border="0" cellspacing="0" 
            cellpadding="0">
              <TBODY>
              <TR>
                <TD height="53"><IMG 
              src="${imgUrl}/left_top_title.gif"></TD></TR>
              <TR>
                <TD height="%" background="${imgUrl}/left_bg.gif" valign="top" 
                style="padding: 5px 0px 0px 5px;"><LINK href="${imgUrl}/admin.css" 
                  rel="stylesheet" type="text/css"> <!-- Menu table 끝 * css사용 해당메뉴의 페이지일때는  class="leftmenu_b", 해당 메뉴페이지가 아닐경우  class="leftmenu"로 사용--------------------------------> 
                  <TABLE width="150" style="margin-top: 10px;" border="0" 
                  cellspacing="0" cellpadding="0">
                    <TBODY>
					<c:forEach var = "menu" items="${menuList}">					
						<tr>
							<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/>
								<a class="leftmenu" href="javascript:goAdminBoardListMain(<c:out value="${menu.menuIndex}" />, <c:out value="${menu.menuType}" />)"><c:out value="${menu.menuName}" /></a>
							</td>
						</tr>				
					</c:forEach>
					<tr>
						<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/><a class="leftmenu_b" href="#">&nbsp;메뉴관리</a></td>
					</tr>
						</TBODY></TABLE></TD></TR></TBODY></TABLE><!-- Left Menu table 끝 --------------------------------> 
                    </TD>
          <TD width="%" align="right" valign="top" style="padding: 20px 10px 0px 0px;">
            <TABLE width="97%" border="0" cellspacing="0" cellpadding="0">
              <TBODY>
              <TR>
                <TD align="left" class="admin_title" background="${imgUrl}/title_bg.gif" 
                valign="middle"><IMG align="absmiddle" src="${imgUrl}/title_icon.gif">메뉴관리</TD></TR>
              <TR>
                <TD height="20">&nbsp;</TD></TR>
              <TR>
									<TD>
										<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
											<TBODY>
												<TR>
													<TD>
														<!--리스트 테이블 시작-->
														<TABLE width="100%" bgcolor="#d9d9d9" border="0"
															cellspacing="1" cellpadding="0">
															<TBODY>
																<TR>
																	<TD height="1" bgcolor="#3f8bc9" colspan="3"></TD>
																</TR>
																<TR>
																	<TD width="10%" align="center" class="top_blue3"
																		bgcolor="#eff3fa">정렬순서</TD>
																	<TD align="left" class="top_blue3"
																		style="padding-left: 10px;" bgcolor="#eff3fa"><INPUT
																		name="morder" id="morder" class="inputText"
																		style="width: 95%;" type="text"  onKeyUp="isNum(this);"
																		value="<c:out value="${menu.morder }"/>"></TD>
																</TR>
																<TR>
																	<TD width="10%" align="center" class="top_blue3"
																		bgcolor="#eff3fa">메뉴명</TD>
																	<TD align="left" class="top_blue3"
																		style="padding-left: 10px;" bgcolor="#eff3fa"><INPUT
																		name="menuName" id="menuName" class="inputText"
																		style="width: 95%;" type="text"
																		value="<c:out value="${menu.menuName }"/>"></TD>
																</TR>
																<c:choose>
																	<c:when test="${menu.menuType == 1}">
																<TR>
																	<TD width="10%" align="center" class="top_blue3"
																		bgcolor="#eff3fa">사용여부</TD>
																	<TD align="left" class="top_blue3"
																		style="padding-left: 10px;" bgcolor="#eff3fa"><INPUT
																		name="useFlag" id="useFlag" type="checkbox"
																		style="width: 95%;"
																		<c:if test="${menu.useFlag ==1 }">checked</c:if>></TD>
																</TR>
																	</c:when>
																	<c:otherwise>
																<TR style="display:none;">
																	<TD width="10%" align="center" class="top_blue3"
																		bgcolor="#eff3fa">사용여부</TD>
																	<TD align="left" class="top_blue3"
																		style="padding-left: 10px;" bgcolor="#eff3fa"><INPUT
																		name="useFlag" id="useFlag" type="checkbox"
																		style="width: 95%;" checked
																		></TD>
																</TR>
																	</c:otherwise>
																</c:choose>
															</TBODY>
														</TABLE>
														<!--리스트 테이블 끝-->
													</TD>
												</TR>
												<TR>
													<TD height="35" align="right"><A href="#" onclick="sendMenuInfo()"> <IMG
															src="${imgUrl}/btn_submit.gif" border="0" hspace="3" />
													</A> <A href="#"><IMG src="${imgUrl}/btn_list.gif" border="0" onclick="goAdminMenuList()">
													</A></TD>
												</TR>
											</TBODY>
										</TABLE>
									</TD>
								</TR>
							</TBODY>
							</TABLE>
							</TD>
							</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<form style="display:none;" id="frm" name="frm" method="post">
	<input type="hidden" name="menuIndex" id="menuIndex" value="${menu.menuIndex}">
	<input type="hidden" name="menuType" id="menuType" value="${menu.menuType}">	
</form>
<script type="text/javascript">
function goAdminBoardListMain(type, menuType) {
		$("#menuIndex").val(type);
		var url;
		
		if (menuType == 0) {
			url = "/admin/adminBoardMain";
		} else {
			url = "/admin/adminBoard2Main";
		}
					
		$("#frm").attr("action", url);
		$("#frm").submit();
		
  }
var goAdminMenuList = function(){
	location.replace("/admin/adminMenuMain");
};	  
</script>
</BODY></HTML>
